<template>
  <!-- 暂时废弃 -->
  <div>
    <div class="listTop">
      节目包含歌曲列表 <span class="musicNum">({{ playlist.length }}首歌)</span>
    </div>
    <table class="musicTable">
      <tbody>
        <tr v-for="(item, index) in playlist" :key="index">
          <td class="tdOne">
            <p class="SerialNumber">
              {{ index }} <span @click="PlayClick(item)"></span>
            </p>
          </td>
          <td class="tdTwo">
            <router-link
              tag="p"
              :to="{ name: 'musicdetail', query: { id: item.id } }"
              class="musciItemColor"
            >
              {{ item.name }} <span>{{ item.alia[0] }}</span>
            </router-link>
          </td>
          <td class="operationHover">
            <p class="musicTime">{{ (item.dt / 1000 / 60).toFixed(2) }}</p>
            <div class="operationBox">
              <span class="play" @click="pushMusicAction(item)"></span>
              <span class="Collection" @click="collectionBtn(item.id)"></span>
              <span class="forward"></span>
              <span class="download"></span>
            </div>
          </td>
          <td>
            <p class="musciItemColor">{{ item.ar[0].name }}</p>
          </td>
          <td>
            <p class="musciItemColor">{{ item.al.name }}</p>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import { musicDetail } from "@/api";
import { mapActions } from "vuex";
export default {
  props: {
    songsIdStr: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      playlist: [],
    };
  },
  created() {
    this.getMusicDetail();
  },
  methods: {
    ...mapActions("musicStore", ["unshiftMusic", "pushMusicAction"]),
    ...mapActions("songSheetStore", [
      "set_change_songSheetBoxIsHide",
      "set_change_musicId",
    ]),
    async PlayClick(item) {
      //直接点击播放当前音乐
      await this.unshiftMusic({ data: item, that: this });
      // this.$bus.$emit("playCurrentMusic");
    },
    //收藏按钮
    collectionBtn(id) {
      this.set_change_musicId(id);
      this.set_change_songSheetBoxIsHide(true);
    },
    getMusicDetail() {
      musicDetail({ ids: this.songsIdStr }).then((res) => {
        console.log(res);
        this.playlist = res.songs;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.listTop {
  height: 32px;
  padding: 0 10px;
  margin-bottom: -1px;
  overflow: hidden;
  background: #f7f7f7;
  border: 1px solid #d9d9d9;
  line-height: 33px;
  font-weight: bold;
  .musicNum {
    font-weight: 100;
    color: #666;
    font-size: 12px;
  }
}
.musicTable {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-collapse: collapse;
  margin-bottom: 30px;
  tbody {
    tr {
      td {
        p {
          padding: 6px 10px;
          line-height: 18px;
          text-align: left;
          font-size: 12px;
          color: #666;
          font-weight: normal;
        }
        .musciItemColor {
          color: #333;
          cursor: pointer;
        }
        .SerialNumber {
          display: flex;
          justify-content: space-between;
          align-items: center;
          span {
            width: 17px;
            height: 17px;
            display: inline-block;
            cursor: pointer;
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -103px;
          }
        }
        .operationBox {
          display: none;
          span {
            display: inline-block;
            width: 18px;
            height: 16px;
            vertical-align: middle;
            margin-left: 5px;
          }
          .play {
            width: 13px;
            height: 13px;
            background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -700px;
          }
          .Collection {
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -174px;
          }
          .forward {
            background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -195px;
          }
          .download {
            background: url("./../../assets/imges/iconTwo.png") no-repeat -81px -174px;
          }
        }
        &.operationHover:hover {
          .musicTime {
            display: none;
          }
          .operationBox {
            display: block;
          }
        }
      }
      .tdOne {
        width: 75px;
      }
      .tdTwo {
        width: 180px;
      }
      .operationHover {
        width: 110px;
      }
      &:nth-of-type(odd) {
        background-color: #f7f7f7;
      }
    }
  }
}
</style>